package com.lagou.component;

import com.lagou.service.MemberService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

@Component
public class ServiceComponent implements CommandLineRunner {

    @Reference
    private MemberService memberService;

    @Override
    public void run(String... args) throws InterruptedException {
        //ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(50, 50, 10L, TimeUnit.MILLISECONDS, new SynchronousQueue(), new DefaultThreadFactory("remote invoke pool"));
        //ExecutorService threadPoolExecutor = Executors.newFixedThreadPool(10);
        while (true) {
            //threadPoolExecutor.execute(() -> memberService.methodA());
            //threadPoolExecutor.execute(() -> memberService.methodB());
            //threadPoolExecutor.execute(() -> memberService.methodC());
            //TimeUnit.MILLISECONDS.sleep(10);
            memberService.methodA();
            memberService.methodB();
            memberService.methodC();
        }
    }
}
